package com.atguigu.ssoserver.refactoring.pojo;

import lombok.AllArgsConstructor;

public class Movie {
    //儿童片
    public static final int CHILDRENS = 2;
    //普通片
    public static final int REGULAR = 0;
    //新片
    public static final int NEW_RELEASE = 1;

    //电影名
    private String _title;

    //租赁价格
    private Price _price;

    public Movie(String title,int priceCode){
        _title=title;
        setPriceCode(priceCode);
    }

    public String getTitle(){
        return _title;
    }

    public int getPriceCode() {
        return _price.getPriceCode();
    }

    public void setPriceCode(int arg) {
        switch (arg){
            case REGULAR:
                _price=new RegularPrice();
                break;
            case CHILDRENS:
                _price=new ChildrensPrice();
                break;
            case NEW_RELEASE:
                _price=new RegularPrice();
                break;
            default:
                throw  new IllegalArgumentException("Incorrect Price Code");
        }
    }


    double getCharge(int daysRented){
        return _price.getCharge(daysRented);
    }


    int getFrequentRenterPoints(int daysRented){
        return _price.getFrequentRenterPoints(daysRented);
    }
}
